<template>
  <div class="nav-container">
    <ul class="nav-list">
      <a :href="`#${item.menuName}`" :id="item.menuName" ref="navList" v-for="item in menuList" :key="item.menuId"><li class="nav-item">{{ item.menuName }}</li></a>
    </ul>
  </div>
</template>

<script>
import {mapActions, mapState} from 'vuex'
export default {
    name: 'MenuNav',
    created() {
      this.getMenuList()
    },
    computed: {
      ...mapState(['menuList'])
    },
    mounted() {
      this.$bus.$on('menuNavClick', (data) => {
          this.$refs.navList.forEach(item => {
            if(item.id == data) {
              item.classList.add('nav-active')
            } else {
              item.classList.remove('nav-active')
            }
          })
      })
    },
    methods: {
      ...mapActions(['getMenuList'])
    }
}
</script>

<style scoped>
.nav-container {
  width: 27%;
  height: 88vh;
  overflow: auto;
  border-radius: 1vh;
  position: sticky;
  /* height: 555px; */
  top: 0;
  margin-left: 10px;
  overflow: auto;
}
.nav-list {
  text-align: center;
  font-size: 14px;
  /* margin-left: 10px; */
  display: flex;
  flex-direction: column;
}
.nav-item {
  background-color: #EFEFEF;
  /* border: 1px solid #333; */
  padding: 6px;
  flex: 10vh 1 0;
  line-height: 10vh;

}
.nav-item:hover,
.nav-active li {
  background-color: #efe;
}
a {
  color: black;
}
a:visited {
  color:black;
}
</style>